package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.LitemallMechanismGoodsAttributeMapper;
import org.linlinjava.litemall.db.domain.LitemallMechanismGoodsAttribute;
import org.linlinjava.litemall.db.domain.LitemallMechanismGoodsAttributeExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LitemallMechanismGoodsAttributeService {
    @Resource
    private LitemallMechanismGoodsAttributeMapper mechanismGoodsAttributeMapper;

    public List<LitemallMechanismGoodsAttribute> queryByGid(Integer goodsId) {
        LitemallMechanismGoodsAttributeExample example = new LitemallMechanismGoodsAttributeExample();
        example.or().andGoodsIdEqualTo(goodsId).andDeletedEqualTo(false);
        return mechanismGoodsAttributeMapper.selectByExample(example);
    }

    public void add(LitemallMechanismGoodsAttribute goodsAttribute) {
        mechanismGoodsAttributeMapper.insertSelective(goodsAttribute);
    }

    public void deleteByGid(Integer gid) {
        LitemallMechanismGoodsAttributeExample example = new LitemallMechanismGoodsAttributeExample();
        example.or().andGoodsIdEqualTo(gid);
        mechanismGoodsAttributeMapper.logicalDeleteByExample(example);
    }
}
